package com.soooft.tickey.security.core.support;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @Description
 * @Author: Fanxl
 * @Date: Created in 2017/9/28 17:03
 */
@Slf4j
public class MyPasswordEncoder implements PasswordEncoder {


    /**
     * 加密
     * @param charSequence
     * @return
     */
    @Override
    public String encode(CharSequence charSequence) {

        return null;
    }

    /**
     * 解密
     * @param rawPassword
     * @param encodedPassword
     * @return
     */
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        String[] str = encodedPassword.split(",");
        String salt = str[1];
        String trueEncodedPw = str[0];
        String pw = MD5Util.md5(rawPassword+"", salt);
        return trueEncodedPw.equals(pw);
    }




}
